package com.xbongbong.saas.domain.dao;

import com.xbongbong.saas.domain.entity.CustomerStageEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 客户阶段dao层接口
 *
 * @author haibin.zhang
 * @date 2019-02-13 13:50
 */
@Repository
@Mapper
public interface CustomerStageDao {

    List<CustomerStageEntity> findEntitys(@Param("param") Map<String,Object> param);

    CustomerStageEntity getByKey(@Param("key") Long key, @Param("corpid") String corpid);

    /**
     * 通过formId + code获取到一个阶段实体
     * 同一个form下code肯定唯一，但是多个form之间可能不唯一（新初始化的form都用的默认阶段code - 1、2、3、4...）
     * @param corpid 公司id
     * @param formId 模板id
     * @param code 阶段code
     * @return com.xbongbong.saas.domain.entity.CustomerStageEntity
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    CustomerStageEntity getByCode(@Param("corpid") String corpid, @Param("formId") Long formId, @Param("code") String code);

    Long insert(CustomerStageEntity entity);

    Long update(CustomerStageEntity entity);

    void insertBatch(List<CustomerStageEntity> list);

    Integer getEntitysCount(@Param("param") Map<String,Object> param);

    void updateBatch(@Param("list") List<CustomerStageEntity> customerStageEntityList, @Param("corpid") String corpid);

    void updateBatchDefaultAndLinkOption(@Param("list") List<CustomerStageEntity> customerStageEntityList, @Param("corpid") String corpid);

    void updateBatch4MirrorRollback(@Param("list") List<CustomerStageEntity> customerStageEntityList, @Param("corpid") String corpid);

    void updateBatch4Script(@Param("list") List<CustomerStageEntity> customerStageEntityList);

    Integer deleteBatch(@Param("list") List<CustomerStageEntity> customerStageEntities, @Param("corpid") String corpid);

    Integer insert4Script(CustomerStageEntity entity);

    void insertBatch4Script(List<CustomerStageEntity> list);
}
